CentOS 6
Sponsored Link

OpenStack Havana - Use Virtual Storage(Multi-Backend)
2013/10/28
 
It's possible to use Virtual Storage provided by Cinder for Virtual Machine Instance.
This example shows to set to use GlusterFS for Virtual Storage.
[1]
Configure NFS Server in your LAN first.
This example uses a shared directory "/storage" provided by NFS on "nfs.srv.world".
[2]
Configure GlusterFS Server in your LAN first.
This example uses a replication volume "/vol01" provided by "gfs01" and "gfs02".
[3] Install some packages first.
[root@dlp ~(keystone)]#
yum --enablerepo=epel -y install glusterfs glusterfs-fuse  
# install from EPEL
[4] Configure Cinder
[root@dlp ~(keystone)]#
vi /etc/cinder/cinder.conf
# line 390: uncomment and change

enabled_backends=
nfs,glusterfs
# add at the last

[nfs]
volume_driver=cinder.volume.drivers.nfs.NfsDriver
volume_backend_name=NFS
nfs_shares_config=/etc/cinder/nfs_shares
nfs_mount_point_base=/var/lib/cinder/nfs
[glusterfs]
volume_driver=cinder.volume.drivers.glusterfs.GlusterfsDriver
volume_backend_name=GlusterFS
glusterfs_shares_config=/etc/cinder/glusterfs_shares
glusterfs_mount_point_base=/var/lib/cinder/glusterfs
[root@dlp ~(keystone)]#
vi /etc/nova/nova.conf
# line 2014: uncomment

libvirt_volume_drivers=iscsi=nova.virt.libvirt.volume.LibvirtISCSIVolumeDriver,i
ser=nova.virt.libvirt.volume.LibvirtISERVolumeDriver,local=nova.virt.libvirt.vol
ume.LibvirtVolumeDriver,fake=nova.virt.libvirt.volume.LibvirtFakeVolumeDriver,rb
d=nova.virt.libvirt.volume.LibvirtNetVolumeDriver,sheepdog=nova.virt.libvirt.vol
ume.LibvirtNetVolumeDriver,nfs=nova.virt.libvirt.volume.LibvirtNFSVolumeDriver,a
oe=nova.virt.libvirt.volume.LibvirtAOEVolumeDriver,glusterfs=nova.virt.libvirt.v
olume.LibvirtGlusterfsVolumeDriver,fibre_channel=nova.virt.libvirt.volume.Libvir
tFibreChannelVolumeDriver,scality=nova.virt.libvirt.volume.LibvirtScalityVolumeD
river
# line 2172: uncomment and change

nfs_mount_point_base=
/var/lib/cinder/nfs
# line 2184: uncomment and change

glusterfs_mount_point_base=
/var/lib/cinder/glusterfs
[root@dlp ~(keystone)]#
vi /etc/cinder/nfs_shares
# create new: specify NFS shared directory

nfs.srv.world:/storage
[root@dlp ~(keystone)]#
chmod 640 /etc/cinder/nfs_shares

[root@dlp ~(keystone)]#
chgrp cinder /etc/cinder/nfs_shares

[root@dlp ~(keystone)]#
mkdir /var/lib/cinder/nfs

[root@dlp ~(keystone)]#
chown cinder. /var/lib/cinder/nfs

[root@dlp ~(keystone)]#
vi /etc/cinder/glusterfs_shares
# create new: specify GlusterFS volume

gfs01.srv.world:/vol01
[root@dlp ~(keystone)]#
chmod 640 /etc/cinder/glusterfs_shares

[root@dlp ~(keystone)]#
chgrp cinder /etc/cinder/glusterfs_shares

[root@dlp ~(keystone)]#
mkdir /var/lib/cinder/glusterfs

[root@dlp ~(keystone)]#
chown cinder. /var/lib/cinder/glusterfs

[root@dlp ~(keystone)]#
/etc/rc.d/init.d/openstack-cinder-volume restart

Stopping openstack-cinder-volume: [ OK ]
Starting openstack-cinder-volume: [ OK ]
[root@dlp ~(keystone)]#
/etc/rc.d/init.d/openstack-nova-compute restart

Stopping openstack-nova-compute: [ OK ]
Starting openstack-nova-compute: [ OK ]
[5] Create volume types.
[root@dlp ~(keystone)]#
cinder type-create nfs

+--------------------------------------+------+
|                  ID                  | Name |
+--------------------------------------+------+
| 177270db-707f-4298-b2c5-fd1fee597efc | nfs  |
+--------------------------------------+------+

[root@dlp ~(keystone)]#
cinder type-create glusterfs

+--------------------------------------+-----------+
|                  ID                  |    Name   |
+--------------------------------------+-----------+
| 7e85590d-29ae-4797-9ba0-9a8eed51709c | glusterfs |
+--------------------------------------+-----------+

[root@dlp ~(keystone)]#
cinder type-list

+--------------------------------------+-----------+
|                  ID                  |    Name   |
+--------------------------------------+-----------+
| 177270db-707f-4298-b2c5-fd1fee597efc |    nfs    |
| 7e85590d-29ae-4797-9ba0-9a8eed51709c | glusterfs |
+--------------------------------------+-----------+
[6] Associates volume types set in [5] and names set in cinder.conf.
[root@dlp ~(keystone)]#
cinder type-key nfs set volume_backend_name=NFS

[root@dlp ~(keystone)]#
cinder type-key glusterfs set volume_backend_name=GlusterFS

[root@dlp ~(keystone)]#
cinder extra-specs-list

+--------------------------------------+-----------+----------------------------------------+
|                  ID                  |    Name   |              extra_specs               |
+--------------------------------------+-----------+----------------------------------------+
| 177270db-707f-4298-b2c5-fd1fee597efc |    nfs    |    {u'volume_backend_name': u'NFS'}    |
| 7e85590d-29ae-4797-9ba0-9a8eed51709c | glusterfs | {u'volume_backend_name': u'GlusterFS'} |
+--------------------------------------+-----------+----------------------------------------+
[7] Create volumes with specifying volume types.
[root@dlp ~(keystone)]#
cinder create --display_name disk_nfs --volume-type nfs 10

+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2013-10-28T11:41:08.341098      |
| display_description |                 None                 |
|     display_name    |               disk_nfs               |
|          id         | dc91cd73-14ab-414e-b0ba-884f8017616a |
|       metadata      |                  {}                  |
|         size        |                  10                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |                 nfs                  |
+---------------------+--------------------------------------+

[root@dlp ~(keystone)]#
cinder create --display_name disk_glusterfs --volume-type glusterfs 10

+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2013-10-28T11:47:49.842014      |
| display_description |                 None                 |
|     display_name    |            disk_glusterfs            |
|          id         | 50ad85a6-b269-4c4d-ab51-11e26652c6cd |
|       metadata      |                  {}                  |
|         size        |                  10                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |              glusterfs               |
+---------------------+--------------------------------------+

[root@dlp ~(keystone)]#
cinder list

+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
|                  ID                  |   Status  |  Display Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
| 50ad85a6-b269-4c4d-ab51-11e26652c6cd | available | disk_glusterfs |  10  |  glusterfs  |  false   |             |
| dc91cd73-14ab-414e-b0ba-884f8017616a | available |    disk_nfs    |  10  |     nfs     |  false   |             |
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
[8] The Configuration is all OK. Attach volumes to instances like follows.
[root@dlp ~(keystone)]#
nova list

+--------------------------------------+-----------+---------+------------+-------------+--------------------+
| ID                                   | Name      | Status  | Task State | Power State | Networks           |
+--------------------------------------+-----------+---------+------------+-------------+--------------------+
| 081bba5e-0a88-4ae5-9757-645f682d172b | CentOS_64 | SHUTOFF | None       | Shutdown    | network01=10.1.0.2 |
+--------------------------------------+-----------+---------+------------+-------------+--------------------+

[root@dlp ~(keystone)]#
nova volume-attach CentOS_64 50ad85a6-b269-4c4d-ab51-11e26652c6cd auto

+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| serverId | 081bba5e-0a88-4ae5-9757-645f682d172b |
| id       | 50ad85a6-b269-4c4d-ab51-11e26652c6cd |
| volumeId | 50ad85a6-b269-4c4d-ab51-11e26652c6cd |
+----------+--------------------------------------+

[root@dlp ~(keystone)]#
nova volume-attach CentOS_64 50ad85a6-b269-4c4d-ab51-11e26652c6cd auto

+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdc                             |
| serverId | 081bba5e-0a88-4ae5-9757-645f682d172b |
| id       | dc91cd73-14ab-414e-b0ba-884f8017616a |
| volumeId | dc91cd73-14ab-414e-b0ba-884f8017616a |
+----------+--------------------------------------+
 
Tweet